/* Replication code for Table 6 */ 


use "C:\Users\ls42\Dropbox\google consumer surveys\Replication Materials\framing_10qn.dta", clear

/*we create a variable saidtoolittle where 1=respondents answer too little and 0=otherwise */

gen saidtoomuch=0
replace saidtoomuch=1 if Question3Answer=="Too Much"
replace saidtoomuch=. if Question3Answer=="Don't Know"  /* remove dont'knows */


/*  create pid variable where leaners are recoded into partisans */
encode Question5Answer, gen(pid)

capture drop newpid
gen newpid=.
replace newpid=1 if pid==4|pid==2
replace newpid=2 if pid==1
replace newpid=3 if pid==5|pid==3   /*  1=Democrat, 2=Independent, 3=Republican */


/*  create ideology variable where the extremes and regular ideologues are combined */

encode Question6Answer, gen(ideology)
capture drop newideo
gen newideo=.
replace newideo=1 if ideology==3|ideology==4
replace newideo=2 if ideology==5
replace newideo=3 if ideology==1|ideology==2  /*  1=Liberal, 2=Moderate, 3=Conservative */


/*  create attitude towards Blacks variable */

encode Question10Answer1Havingle, gen(inborn)
recode inborn .=0

encode Question10Answer2Lackofe, gen(edu)
recode edu .=1 1=0

encode Question10Answer3Discrimin, gen(discrimination)
recode discrimination .=1 1=0

encode Question10Answer4Lackofm, gen(motivation)
recode motivation .=0

capture drop racist
gen racist = (inborn+edu+discrimination+motivation)/4
recode racist 0=1 0.25=1 0.5=2 0.75=3 1=3              /*  1=most favorable, 2=moderately favorable, 3=least favorable */


/* treatment effect by pid. */ 

capture drop inter
gen inter=newpid*group
capture drop b*
estsimp logit saidtoomuch group newpid inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'


/* the code below will produce the results shown in row 1 to 3, coloumn 2 and 3 of table 6 */ 
while `a' <= 3 {


setx newpid `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
		/* iterate the loop */
	
	}		
	


/* treatment effect by ideology */ 


capture drop inter
gen inter=newideo*group
capture drop b*
estsimp logit saidtoomuch group newideo inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 4 to 6, coloumn 2 and 3 of table 6 */ 
while `a' <= 3 {


setx newideo `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
			/* iterate the loop */
	
	}		




/* treatment effect by attitude toward blacks */ 


capture drop inter
gen inter=racist*group
capture drop b*
estsimp logit saidtoomuch group racist inter


local a=1	
local b=1
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 7 to 9, coloumn 2 and 3 of table 6 */ 
while `a' <= 3 {


setx racist `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
			/* iterate the loop */
	
	}		


	
/* Replication code for Table 7 */ 

/* treatment effect by inferred gender */ 


recode gender 3=.  /* drop those whose inferred gender is unknown */

capture drop inter
gen inter=gender*group
capture drop b*
estsimp logit saidtoomuch group gender inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 1 and 2, coloumn 2 and 3 of table 7 */ 
while `a' <= 2 {


setx gender `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
		/* iterate the loop */
	
	}		


/* treatment effect by reported gender */ 


encode Question2Answer, gen(gender_report)

recode gender_report 2=. 3=2 /* drop those who answered "I prefer not to say" */

capture drop inter
gen inter=gender_report*group
capture drop b*
estsimp logit saidtoomuch group gender_report inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 1 and 2, coloumn 4 and 5 of table 7 */ 

while `a' <= 2 {


setx gender_report `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				

	}		



/* treatment effect by inferred age */ 


recode age 7=. /* drop those whose inferred age is unknown */

capture drop inter
gen inter=age*group
capture drop b*
estsimp logit saidtoomuch group age inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 3 to 8, coloumn 2 and 3 of table 7 */ 

while `a' <= 6 {


setx age `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
			/* iterate the loop */
	
	}		


/* treatment effect by reported age */ 


encode Question1Answer, gen(age_report)

recode age_report 7=. /* drop those who answered "I prefer not to say" */

capture drop inter
gen inter=age_report*group
capture drop b*
estsimp logit saidtoomuch group age_report inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 3 to 8, coloumn 4 and 5 of table 7 */ 
while `a' <= 6 {


setx age_report `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
	/* iterate the loop */
	
	}		



/* treatment effect by inferred income */ 


recode income 7/8=. 2/3=5 4=2 5=3 6=4 /* drop those whose inferred income is unknown. I also recode the income categories in ascending order 
                                         and combined the 150K+ category into 100K+ category */


capture drop inter
gen inter=income*group
capture drop b*
estsimp logit saidtoomuch group income inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 9 to 13, coloumn 2 and 3 of table 7 */
while `a' <= 5 {


setx income `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
		/* iterate the loop */
	
	}		




/* treatment effect by reported income */ 
capture drop income_report
encode Question8Answer, gen(income_report)

recode income_report 2/3=5 4=2 5=3 6=4 /*I recode the income categories in ascending order 
                                         and combined the 150K+ category into 100K+ category */



capture drop inter
gen inter=income_report*group
capture drop b*
estsimp logit saidtoomuch group income_report inter


local a=1	
local welf=2
local assist=1

setx group `welf'  inter `a'*`welf'

/* the code below will produce the results shown in row 9 to 13, coloumn 4 and 5 of table 7 */
while `a' <= 5 {


setx income_report `a' 

capture drop pred
simqi fd(prval(1)genpr(pred))changex(group `assist' `welf' inter `a'*`assist' `a'*`welf') 
 
		
local a = `a' + 1				
		/* iterate the loop */
	
	}		
































